<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加文档</title>
    <link rel="stylesheet" href="public/layui/css/layui.css">
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
        }
    </style>
</head>

<body>
    <form class="layui-form layui-form-pane layui-padding-3" lay-filter="edit" action="">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">文档内容</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入文档内容" class="layui-textarea" name="content"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" lay-submit lay-filter="add">添加</button>
        </div>
    </form>
    <script src="./public/layui/layui.js"></script>
    <script>
        layui.use(function () {
            var form = layui.form
            var $ = layui.$
            var laydate = layui.laydate
            form.on('submit(add)', function (data) {
                field = data.field
                $.post('?p=index&c=file&a=doAdd', field, (res) => {
                    if (res.code == 200) {
                        layer.msg('添加成功')
                    } else {
                        layer.msg(res.msg)
                    }
                })
                return false
            })
        })
    </script>
</body>

</html>